package 极客算法训练营.chapter11;

public class 寻找旋转排序数组中的最小值 {
    class Solution {
        public int findMin(int[] nums) {
            int left = 0, right = nums.length - 1, mid = -1;
            if(nums[right] >= nums[left]) return nums[left];
            while (left <= right) {
                mid = (left + right) / 2;
                if(mid == left) break;
                if(nums[mid] > nums[0]) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            return nums[mid + 1];
        }
    }
}
